﻿using System;
using System.Collections.Generic;
using QuailServices.QuailDataServiceReference;

namespace Quail
{
    /// <summary>
    /// DumbLogger doesn't log anything.  It's a blank implementation of ITaskFactory
    /// </summary>
    public class DumbLogger : ITaskFactory
    {
        ~DumbLogger()
        {
            Dispose(false);
        }

        /// <summary>
        /// Gets a value indicating whether the logger supports screenshots
        /// </summary>
        public bool SupportsScreenshot
        {
            get { return false; }
        }

        /// <summary>
        /// Creates a root task object
        /// </summary>
        /// <param name="testsession">The test session.</param>
        /// <param name="taskname">the task name</param>
        /// <returns>a new DumbLoggerTask</returns>
        public ITaskImplementor CreateRootTask(TestSession testsession, string taskname)
        {
            return new DumbLoggerTask();
        }

        /// <summary>
        /// does nothing
        /// </summary>
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
        }

        /// <summary>
        /// DumbLoggerTask doesn't log anything.  It's a blank implementation of ITaskImplementor
        /// </summary>
        public class DumbLoggerTask : ITaskImplementor
        {
            ~DumbLoggerTask()
            {
                Dispose(false);
            }

            /// <summary>
            /// Does nothing 
            /// </summary>
            /// <param name="state">The parameter is not used.</param>
            /// <param name="message">The parameter is not used.</param>
            /// <param name="url">the url</param>
            public void AddImpl(LogStatus state, string message, string url)
            {
            }

            /// <summary>
            /// Returns a DumbLoggerTask
            /// </summary>
            /// <param name="testsession">The test session.</param>
            /// <param name="taskname">The parameter is not used.</param>
            /// <returns>A DumbLoggerTask</returns>
            public ITaskImplementor BeginNewTaskImpl(TestSession testsession, string taskname)
            {
                return new DumbLoggerTask();
            }

            /// <summary>
            /// Does nothing
            /// </summary>
            /// <param name="state">The parameter is not used.</param>
            /// <param name="filename">The parameter is not used.</param>
            /// <param name="message">The parameter is not used.</param>
            public void ScreenshotImpl(LogStatus state, string filename, string message)
            {
            }

            /// <summary>
            /// Does nothing
            /// </summary>
            public void RollbackImpl()
            {
            }

            /// <summary>
            /// Does nothing
            /// </summary>
            /// <param name="attribute">unused attribute parameter</param>
            /// <param name="message">unused message parameter</param>
            public void AddAttributeImpl(string attribute, string message)
            {
            }

            /// <summary>
            /// Does nothing
            /// </summary>
            /// <param name="state">unused state parameter</param>
            public void FinishImpl(LogStatus state)
            {
            }

            /// <summary>
            /// does nothing
            /// </summary>
            public void Dispose()
            {
                Dispose(true);
                GC.SuppressFinalize(this);
            }

            protected virtual void Dispose(bool disposing)
            {
            }


            /// <summary>
            /// Does nothing
            /// </summary>
            public void FlushImpl()
            {
            }

            /// <summary>
            /// Does nothing
            /// </summary>
            /// <param name="logger">The test logger</param>
            public void StopImpl(TestLogger logger)
            {
            }

            /// <summary>
            /// Stores the network traffic.
            /// </summary>
            /// <param name="url">the url or name for the traffic</param>
            /// <param name="remoteControlUrl">the url or name for the traffic remote control host</param>
            /// <param name="urlCounter">the number of times this url has been hit in this test run</param>
            /// <param name="traffic">The traffic.</param>
            public void StoreNetworkTrafficImpl(string url, string remoteControlUrl, int urlCounter, int msUntilReady, List<NetworkTrafficData> traffic)
            {
            }

            public void StoreMonitorImpl(LogStatus state, Enum scenario, string message)
            {
                
            }
        }
    }
}
